home *** CD-ROM | disk | FTP | other *** search
/ IRIX Installation Tools & Overlays 2002 November / SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso / dist / cluster_admin.idb / usr / cluster / bin / cdbreinit.z / cdbreinit
Text File  |  2002-10-15  |  4KB  |  149 lines

  1. #!/bin/sh
  2. #                                                                         
  3. #  Copyright (C) 1998, Silicon Graphics, Inc.                             
  4. #  All Rights Reserved.                                                   
  5. #                                                                         
  6. #  UNPUBLISHED -- Rights reserved under the copyright laws of the United  
  7. #  States.  Use of a copyright notice is precautionary only and does not  
  8. #  imply publication or disclosure.                                       
  9. #                                                                         
  10. #  THIS SOFTWARE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF     
  11. #  SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR 
  12. #  DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN    
  13. #  PERMISSION OF SILICON GRAPHICS, INC.                                   
  14. #                                                                         
  15. #  U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND                               
  16. #  Use, duplication or disclosure by the Government is subject to         
  17. #  restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph       
  18. #  (c)(1)(ii) of the Rights in Technical Data and Computer Software       
  19. #  clause at DFARS 252.227-7013 and/or in similar or successor clauses    
  20. #  in the FAR, or the DOD or NASA FAR Supplement.  Unpublished-- rights   
  21. #  reserved under the copyright laws of the United States.                
  22. #  Contractor/manufacturer is Silicon Graphics, Inc.,                     
  23. #  2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.                 
  24. #
  25. #
  26. # Simple script to delete an existing CDB and then recreate a new one
  27. # with the same name.
  28. #
  29.  
  30. BINDIR=${rbase:-}/usr/cluster/bin
  31. CDB_DB_DIR=$rbase/var/cluster/cdb
  32.  
  33. # cmond command timeout in seconds
  34. CMON_TMOUT=10
  35.  
  36. CMON_RESTART="${BINDIR}/cmon_ctrl restart -r -f -t ${CMON_TMOUT} -g"
  37. CLUSTER_ADMIN_GRP=cluster_admin
  38.  
  39. #
  40. # Check if a database filename was specified
  41. #
  42. if [ "$1" = "" ]; then
  43.     echo "Assuming /var/cluster/cdb/cdb.db database"
  44.     DBFILE=/var/cluster/cdb/cdb.db
  45. else
  46.     DBFILE=$1
  47. fi
  48.  
  49. DBDIR="$DBFILE#"
  50. PROMPT="Continue[y/n] "
  51.  
  52.  
  53. #
  54. # Make sure the user wants to delete this cdb and give
  55. # them the option to abort if not
  56. #
  57. echo "Preparing to delete database at $DBFILE!"
  58. read RESP?$PROMPT
  59.  
  60. if [ "$RESP" != "y" ]; then
  61.     # Abort
  62.     echo "Response was not yes, exiting..."
  63.     exit 0;
  64. fi
  65.  
  66. #
  67. # Stop all cluster process
  68. #
  69. echo "Stopping cluster processes"
  70. /sbin/chkconfig cluster on
  71. /etc/init.d/cluster stop
  72.  
  73. # kill fs2d if running
  74. echo "Stopping fs2d process"
  75. /sbin/killall -TERM fs2d
  76.  
  77. #
  78. # Delete the cdb database directory and header file
  79. #
  80.  
  81. echo "Removing database at $DBFILE..."
  82.  
  83. #
  84. # Make sure the database header file exists, if it does, remove it
  85. #
  86. if [ ! -f $DBFILE ]; then
  87.     echo "Database header file $DBFILE doesn't exist"
  88. else
  89.     echo "Removing database header file $DBFILE..."
  90.     /sbin/rm -f $DBFILE
  91.  
  92.     echo "Deleted CDB header file $DBFILE"
  93. fi
  94.  
  95. #
  96. # Make sure the database directory exists, if it does, remove it
  97. #
  98. if [ ! -d $DBDIR ]; then
  99.     echo "Database directory $DBDIR doesn't exist"
  100. else
  101.     echo "Removing database directory $DBDIR..."
  102.     /sbin/rm -rf $DBDIR
  103.  
  104.     echo "Deleted CDB database at $DBFILE"
  105. fi
  106.  
  107. echo "Recreating new CDB database at $DBFILE"
  108.  
  109. #
  110. # If the CDB does not exist, create default CDB header and basic nodes.
  111. #
  112. if [ ! -f $DBFILE ]; then
  113.     /sbin/mkdir -p $CDB_DB_DIR
  114.     $BINDIR/cdbnew $DBFILE
  115. fi
  116.  
  117.  
  118. #
  119. # Create HA and CXFS information in the database
  120. #
  121. if [ -f $DBFILE ]; then
  122.     # Check if local HA tree has been created
  123.     $BINDIR/cdbutil node "#local#HA" > /dev/null 2>&1
  124.     if [ $? -ne 0 ]; then
  125.     # if the CDB node does not exist, create local HA nodes
  126.     $BINDIR/cdbutil -F $BINDIR/cdb-init-local-HA-nodes -q dbfile $DBFILE
  127.     echo "Added HA information to CDB database in $DBFILE"
  128.     fi
  129.     # Check if local CXFS tree has been created
  130.     $BINDIR/cdbutil node "#local#Cellular" > /dev/null 2>&1
  131.     if [ $? -ne 0 ]; then
  132.     # if the CDB node does not exist, create local CXFS nodes
  133.     $BINDIR/cdbutil -F $BINDIR/cdb-init-local-CX-nodes -q dbfile $DBFILE
  134.     echo "Added CXFS information to CDB database in $DBFILE"
  135.     fi
  136. fi
  137.  
  138. #
  139. # Kill fs2d process and start cluster processes.
  140. # fs2d would have started automatically when CDB is created.
  141. #
  142. /sbin/chkconfig cluster on
  143. /etc/init.d/cluster start
  144. echo "Started cluster processes"
  145.  
  146. # Exit with status 0
  147. #
  148. exit 0
  149.